home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
-
- nt.c
-
- WinNT-specific routines for use with Info-ZIP's UnZip 5.1 and later.
-
- ---------------------------------------------------------------------------*/
-
-
- #include "unzip.h"
-
-
- /**********************/
- /* Function mapattr() */
- /**********************/
-
- int mapattr() /* identical to MS-DOS, OS/2 versions */
- {
- /* set archive bit (file is not backed up): */
- pInfo->file_attr = (unsigned)crec.external_file_attributes | 32;
- return 0;
-
- } /* end function mapattr() */
-
-
-
-
-
- /**************************************/
- /* Function set_file_time_and_close() */
- /**************************************/
-
- void set_file_time_and_close()
- {
- FILETIME ft; /* 64-bit value made up of two 32 bit [low & high] */
- WORD wDOSDate; /* for vconvertin from DOS date to Windows NT */
- WORD wDOSTime;
- HANDLE hFile; /* file handle (defined in Windows NT) */
-
-
- /* don't set the time stamp on standard output */
- if (cflag) {
- close(outfd);
- return;
- }
-
- /* Copy and/or convert time and date variables, if necessary; then set the
- * file time/date. */
- wDOSTime = (WORD)lrec.last_mod_file_time;
- wDOSDate = (WORD)lrec.last_mod_file_date;
-
- /* The DosDateTimeToFileTime() function converts a DOS date/time
- * into a 64 bit Windows NT file time */
- DosDateTimeToFileTime(wDOSDate, wDOSTime, &ft);
-
- /* Close the file and then re-open it using the Win32
- * CreateFile call, so that the file can be created
- * with GENERIC_WRITE access, otherwise the SetFileTime
- * call will fail. */
- close(outfd);
-
- #if 0 /* this was at the very end of the routine (never reached): here? */
- if (!SetFileAttributes(filename, pInfo->file_attr & 0x7F))
- fprintf(stderr, "\nwarning (%d): could not set file attributes\n",
- GetLastError());
- #endif
-
- hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (!SetFileTime(hFile, NULL, NULL, &ft))
- printf("\nSetFileTime failed: %d\n", GetLastError());
- CloseHandle(hFile);
- return;
-
- } /* end function set_file_time_and_close() */
-